package com.chuantou.yuba.api.to;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

/**
 * 帐号信息TO
 * 
 * @author Administrator
 * 
 */
public class UserTO implements Parcelable {
	// 帐号ID
	@SerializedName("uid")
	private long uid;
	// 手机号码
	@SerializedName("mobile")
	private String mobile;
	// 邮箱
	@SerializedName("email")
	private String email;
	// 昵称
	@SerializedName("username")
	private String username;
	// 性别，1女2男
	@SerializedName("sex")
	private int sex;
	// 生日
	@SerializedName("birthday")
	private String birthday;
	// 头像
	@SerializedName("avatar")
	private String avatar;
	// 封面
	@SerializedName("background")
	private String cover;
	// 个性签名
	@SerializedName("mood")
	private String mood;
	// 省份ID
	@SerializedName("state_id")
	private String stateId;
	// 省份名称
	@SerializedName("state")
	private String stateName;
	// 城市名称
	@SerializedName("city")
	private String cityName;
	// 城市ID
	@SerializedName("city_id")
	private String cityId;
	// 环信帐号
	@SerializedName("hxaccount")
	private String hxAccount;
	// 环信密码
	@SerializedName("hxpwd")
	private String hxpwd;
	// 钓龄
	@SerializedName("fishing_age")
	private int fishAge;
	// 常去钓鱼地点
	@SerializedName("fishing_address")
	private String fishingAddress;
	// 登录 令牌
	@SerializedName("accesstoken")
	private String token;
	// 令牌过期时间（单位秒）
	@SerializedName("expire")
	private long expire;
	// 服务端不会返回，仅做本地存储使用
	@SerializedName("password")
	private String password;
	// 登录时间，服务端不会返回,仅做本地存储使用
	@SerializedName("loginTime")
	private long loginTime;
	// 积分数
	@SerializedName("score")
	private int integral;
	// 动态数
	@SerializedName("feed_total")
	private int trendsCount;
	// 粉丝数
	@SerializedName("fans_total")
	private int fansCount;
	// 关注数
	@SerializedName("collect_total")
	private int followCount;
	//
	@SerializedName("platform")
	private String platform;

	public UserTO() {

	}

	public UserTO(Parcel source) {
		uid = source.readLong();
		mobile = source.readString();
		email = source.readString();
		username = source.readString();
		sex = source.readInt();
		birthday = source.readString();
		avatar = source.readString();
		mood = source.readString();
		stateId = source.readString();
		stateName = source.readString();
		cityName = source.readString();
		cityId = source.readString();
		fishAge = source.readInt();
		fishingAddress = source.readString();
		token = source.readString();
		expire = source.readLong();
		password = source.readString();
		loginTime = source.readLong();
		hxAccount = source.readString();
		hxpwd = source.readString();
		cover = source.readString();
		integral = source.readInt();
		trendsCount = source.readInt();
		fansCount = source.readInt();
		followCount = source.readInt();
		platform = source.readString();
	}

	/**
	 * 是否TOKEN已经过期
	 * 
	 * @return
	 */
	public boolean isExpired() {
		return loginTime + expire * 1000 < System.currentTimeMillis();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(uid);
		dest.writeString(mobile);
		dest.writeString(email);
		dest.writeString(username);
		dest.writeInt(sex);
		dest.writeString(birthday);
		dest.writeString(avatar);
		dest.writeString(mood);
		dest.writeString(stateId);
		dest.writeString(stateName);
		dest.writeString(cityName);
		dest.writeString(cityId);
		dest.writeInt(fishAge);
		dest.writeString(fishingAddress);
		dest.writeString(token);
		dest.writeLong(expire);
		dest.writeString(password);
		dest.writeLong(loginTime);
		dest.writeString(hxAccount);
		dest.writeString(hxpwd);
		dest.writeString(cover);
		dest.writeInt(integral);
		dest.writeInt(trendsCount);
		dest.writeInt(fansCount);
		dest.writeInt(followCount);
		dest.writeString(platform);
	}

	public static final Creator<UserTO> CREATOR = new Creator<UserTO>() {

		@Override
		public UserTO[] newArray(int size) {
			return new UserTO[size];
		}

		@Override
		public UserTO createFromParcel(Parcel source) {
			return new UserTO(source);
		}
	};

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getMood() {
		return mood;
	}

	public void setMood(String mood) {
		this.mood = mood;
	}

	public String getStateId() {
		return stateId;
	}

	public void setStateId(String stateId) {
		this.stateId = stateId;
	}

	public String getStateName() {
		return stateName;
	}

	public void setStateName(String stateName) {
		this.stateName = stateName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	public int getFishAge() {
		return fishAge;
	}

	public void setFishAge(int fishAge) {
		this.fishAge = fishAge;
	}

	public String getFishingAddress() {
		return fishingAddress;
	}

	public void setFishingAddress(String fishingAddress) {
		this.fishingAddress = fishingAddress;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public long getExpire() {
		return expire;
	}

	public void setExpire(long expire) {
		this.expire = expire;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public long getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(long loginTime) {
		this.loginTime = loginTime;
	}

	public String toJsonString() {
		Gson gson = new Gson();
		return gson.toJson(this);
	}

	public String getHxAccount() {
		return hxAccount;
	}

	public void setHxAccount(String hxAccount) {
		this.hxAccount = hxAccount;
	}

	public String getHxpwd() {
		return hxpwd;
	}

	public void setHxpwd(String hxpwd) {
		this.hxpwd = hxpwd;
	}

	public String getCover() {
		return TextUtils.isEmpty(cover) ? avatar : cover;
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	public int getIntegral() {
		return integral;
	}

	public void setIntegral(int integral) {
		this.integral = integral;
	}

	public int getTrendsCount() {
		return trendsCount;
	}

	public void setTrendsCount(int trendsCount) {
		this.trendsCount = trendsCount;
	}

	public int getFansCount() {
		return fansCount;
	}

	public void setFansCount(int fansCount) {
		this.fansCount = fansCount;
	}

	public int getFollowCount() {
		return followCount;
	}

	public void setFollowCount(int followCount) {
		this.followCount = followCount;
	}

	public String getPlatform() {
		return platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}

}
